package com.jtpay.sdk.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.Checkable;
import android.widget.FrameLayout;
import android.widget.RadioButton;
import android.widget.TextView;

import com.jtpay.sdk.R;


/**
 * Created by Steven on 2016/6/22 0022.
 */

public class ChoiceView extends FrameLayout implements Checkable {
    private TextView mTextView;
    private RadioButton mRadioButton;

    public ChoiceView(Context context) {
        this(context, null);
    }

    public ChoiceView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public ChoiceView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        LayoutInflater.from(context).inflate(R.layout.layout_channel_item, this);
        mRadioButton = (RadioButton) findViewById(R.id.rb);
        mTextView = (TextView) findViewById(R.id.text_name);
    }

    @Override
    public void setChecked(boolean checked) {
        mRadioButton.setChecked(checked);
        mTextView.setSelected(checked);
    }

    @Override
    public boolean isChecked() {
        return mRadioButton.isChecked();
    }

    @Override
    public void toggle() {
    }

    public void setText(String text) {
        mTextView.setText(text);
    }

    public TextView getTextView() {
        return mTextView;
    }
}
